package br.com.acs.CameraIP.dao;

import java.util.List;

import org.hibernate.Session;


import br.com.acs.CameraIP.model.Camera;
import br.com.acs.CameraIP.util.HibernateUtil;

public class CameraDaoImp  implements CameraDao{

/*	@Override
	public Camera getCamera(long id) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
//		Transaction t = session.beginTransaction();
//		t.commit();
		return (Camera) session.load(Camera.class, id);
	}*/

		@SuppressWarnings("unchecked")
	    public List<Camera> getCameraPorCliente(long idCliente) {
	    	Session session = HibernateUtil.getSessionFactory().getCurrentSession();
	    	List<Camera> lista = session.createQuery("FROM Camera WHERE idCliente = :idCliente order by nome").setParameter("idCliente",idCliente).list();;
	        return lista;
	    }
	    
	    @Override
	    public Camera getCamera(long id) {
	    	Session session = HibernateUtil.getSessionFactory().getCurrentSession();
	    	return (Camera) session.createQuery("FROM Camera WHERE id = :id").setParameter("id",id).uniqueResult();
	    }

}
